package com.weijian.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weijian.dal.entity.UploadBatch;
import com.weijian.mapper.UploadBatchMapper;
import com.weijian.mapper.UploadMapper;
import com.weijian.service.UploadBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 上传批次服务实现类
 */
@Service
public class UploadBatchServiceImpl extends ServiceImpl<UploadBatchMapper, UploadBatch> implements UploadBatchService {

    @Autowired
    private UploadMapper uploadMapper;

    @Override
    public UploadBatch getByDataId(Integer dataId) {
        return this.lambdaQuery()
                .eq(UploadBatch::getDataId, dataId)
                .one();
    }

    @Override
    public boolean saveOrUpdateBatch(UploadBatch uploadBatch) {
        return this.saveOrUpdate(uploadBatch);
    }

    @Override
    public Integer generateNewDataId() {
        return uploadMapper.getNextDataId();
    }

    @Override
    public Integer allocateBatchId() {
        return generateNewDataId();
    }
}